<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
 
<%@ page import="com.lmpop.trade.ts_category.*" %>
<%@ page import="com.lmpop.trade.tb_commpara.Tb_commparaInfo" %>
<jsp:useBean id="randomId" class="com.lmpop.frame.util.RandomID" scope="page" />  
 
<%
	String cat_id = randomId.GenTradeId();
 
 
	Ts_categoryInfo ts_categoryInfo = new Ts_categoryInfo();
	String class_type="",up_cat_id="000000000000000",class_level="";
	int class_level_int = 1;
	if (request.getParameter("class_type") != null) {
		class_type = request.getParameter("class_type");
	}
	String up_class_name="";       
	if (request.getParameter("up_cat_id") != null) {
		up_cat_id = request.getParameter("up_cat_id");
 
		up_class_name  =ts_categoryInfo.getCatNameById(up_cat_id);
 		
	}
	if (request.getParameter("class_level") != null && !request.getParameter("class_level").equals("")) {
		class_level = request.getParameter("class_level");
		class_level_int = Integer.parseInt(class_level)+1;
	}
	
	Tb_commparaInfo tb_commparaInfo = new Tb_commparaInfo(); 
	String obj_name = tb_commparaInfo.getOneComparaPcode1("40",class_type);

%>
<html>
	<head>
		<title>新增<%=obj_name%>分类</title>
		<link href="/program/admin/index/css/style.css" rel="stylesheet" type="text/css">
 
 
		<!--<script language="javascript" type="text/javascript" src="/program/admin/category/js_category.js"></script>
--> 
     <script language="javascript" type="text/javascript" >
      function subForm(){
	
	if(document.getElementById("cat_name")==null || trim(document.getElementById("cat_name").value)=="")
	{
	  alert("分类名称不能为空！");
	  document.getElementById("cat_name").focus;
	  return false;
	}
	
	if(document.getElementById("up_class_name").value !=null &&document.getElementById("cat_name").value == document.getElementById("up_class_name").value){
	    alert("子类名不能与上级类名相同！");
	    document.getElementById("cat_name").focus;
	    return false;
	}
   document.addForm.submit();
   }
function trim(val)
 {
 
	return val.replace(/(\s*$)/g, "");  
	
}
</script>
<script type="text/javascript" src="/program/admin/js/judgment.js" charset="UTF-8"></script>
	</head>
<body>
	<h1>新增<%=obj_name%>分类</h1>
 
	
	  <table width="100%" align="center" cellpadding="0" cellspacing="0" class="dl_so">
        <tr>
          <td width="9%" align="center"><img src="/program/admin/index/images/ban_01.gif" /></td>
          <td width="91%" align="left">
			  <h4>提示信息:</h4>
			  <span>您在这里新增的分类为<font color="red"><%=class_level_int%></font>级分类。</span>
          </td>
        </tr>
      </table>

	<form action="/doTradeReg.do" method="post" name="addForm">
	
	<table width="100%" class="listtab" cellpadding="1" cellspacing="1" border="0">
		
		<%
		
		if(!up_class_name.equals(""))
{
		
		%>
		<tr>
			<td align="right" width="20%">
				上级分类:
			</td>
			<td><%=up_class_name%></td>
		</tr>
		
		<%
		}
		%>
		<tr>
			<td align="right" width="20%">
				分类名称<font color="#FF0000">*</font>		
			</td>
			<td><input name="up_class_name" id="up_class_name" type="hidden" value="<%=up_class_name %>"/>
			<input name="cat_name" id="cat_name" type="text" maxlength="100" onkeyup="inputNoHorns(this)"   onbeforepaste= "inputNoHorns(this); "/></td>
		</tr>
		
		<tr>
			<td align="right" width="20%">
				是否前台显示:
			</td>
			<td>
				
				<input name="is_dis" id="is_dis1" type="radio" value="0" checked/>
显示
				<input name="is_dis" id="is_dis2" type="radio" value="1" />不显示
				
				</td>
		</tr>
		
		<tr>
			<td align="right" width="20%">
				显示顺序:
			</td>
			<td><input name="sort_no" id="sort_no" type="text" onkeyup="value=value.replace(/[^\d]/g,'')" onbeforepaste="clearSBC()" value="0" maxlength="4" /></td>
		</tr>
		
		<tr>
			<td align="right" width="20%">
				备注:
			</td>
			<td><input name="remark" id="remark" type="text" maxlength="500" onkeyup="inputNoHorns(this)"   onbeforepaste= "inputNoHorns(this); "/></td>
		</tr>
		
	</table>
	
	<table width="100%" cellpadding="0" cellspacing="0" border="0">
		<tr>
			<td align="center">
				<input type="hidden" name="bpm_id" value="7126" />
 
				<input type="hidden" name="cat_id" value="<%=cat_id%>" />
        <input name="up_cat_id" id="up_cat_id" type="hidden" value="<%=up_cat_id%>">
				<input name="cat_level" id="cat_level" type="hidden" value="<%=class_level_int%>">
				<input name="class_type" id="class_type" type="hidden" value="<%=class_type%>">
				<input type="button"  class="buttoncss" name="tradeSub" value="提交" onclick="subForm();" />&nbsp;&nbsp;
				<input type="button"  class="buttoncss" name="tradeRut" value="返回" onclick="window.location.href='/program/admin/category/index.jsp?class_type=<%=class_type%>';"/>
			</td>
		</tr>
	</table>
	</form>
</body>

</html>
